<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>发送数据到服务器</button>
    <script src="https://cdn.bootcdn.net/ajax/libs/socket.io/2.3.0/socket.io.js"></script>
    <script>
      const socket = io.connect();
      document.querySelector("button").onclick = function () {
        socket.emit("msg", "msg from client");
      };

      socket.on("test", (chunk) => {
        console.log(chunk);
      });

      socket.on("disconnect", () => {
        console.log("closed");
      });
    </script>
  </body>
</html>
